package news.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.volley.Response;

import java.util.ArrayList;
import java.util.List;

import bean.News;
import httptool.QLParser;
import httptool.getHttpUrl;
import httptool.takeUrlResource;

/**
 * Created by cch on 2016/6/13.
 */
public class Fragment1 extends Fragment {
//    @Override
//    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
//        super.onActivityCreated(savedInstanceState);
//    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                final TextView textView = new TextView(getActivity());
                takeUrlResource.getJson(getActivity(), getHttpUrl.index, new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        News data = QLParser.parse(s,News.class);
                        List<News.XiaozhiBean> xiaozhi = data.getXiaozhi();//集合中获取xiaozi的数组
                        for (News.XiaozhiBean xz:xiaozhi){
                            String id = xz.getId();
                            String title = xz.getTitle();
                            String senddate = xz.getSenddate();
                            String writer = xz.getWriter();
                            ArrayList<String> imgs = (ArrayList<String>) xz.getImgs();
                        }
//                textView.setText(xiaozhi.get(0).getId());
//                textView.setText((CharSequence) xiaozhi.get(0).getImgs());
                textView.setText(xiaozhi.get(0).getSenddate());
//                textView.setText(xiaozhi.get(0).getWriter());

          /*      News data = QLParser.parse(s, News.class);
                List<News.HotBean> hot = data.getHot();
                for (News.HotBean ss:hot){
                    String id = ss.getId();
                }
                textView.setText(hot.get(0).getWriter());*/


//                News news = QLParser.parse(s, News.class);
//                List<News.HeadBean> head = news.getHead();
//                for (News.HeadBean data:head
//                     ) {
//                    String id =  data.getId();
//                }
//                textView.setText(head.get(0).getTitle());

            }
        });
        return textView;
    }
}
